feat(sample-app): admin seed runner + datasource/JWT config for e2e#24
Merged
Conversation
…fig for e2e
Sets up the sample app so the admin UI can log in immediately
against it. Needed for end-to-end verification of the full stack
(admin-ui + devslab-kit) — previously the app booted with zero
users and the UI's login screen had nothing to authenticate against.
Seed runner
-----------
- New SampleSeedRunner (ApplicationRunner) registered as a bean from
SampleApplication. On first boot it provisions:
* Tenant "default"
* Role PLATFORM_ADMIN bound to that tenant
* 16 admin.* permissions covering every admin-api endpoint
(admin.user.read/write, admin.role.read/write, ...
admin.permission.*, admin.group.*, admin.menu.*,
admin.tenant.*, admin.policy.test, admin.audit.read,
admin.diagnostics.run, admin.settings.read)
* Each admin.* permission granted to PLATFORM_ADMIN
* User admin / admin (configurable) with PLATFORM_ADMIN role
- Every step is idempotent (findByCode / findByLoginId before
create). Re-running on an already-seeded DB is a no-op.
- New SampleSeedProperties (sample.seed.*) — disable with
sample.seed.enabled=false; admin loginId / password / email
overridable via SAMPLE_SEED_ADMIN_* env vars.
application.yaml
----------------
- Add Spring datasource block pointing at the same Postgres that
devslab-kit-admin-ui's docker-compose stands up by default
(jdbc:postgresql://localhost:5432/devslab_kit, devslab/devslab).
All four values overridable via DEVSLAB_DATASOURCE_*.
- Add Redis host/port (DEVSLAB_REDIS_*).
- jpa.open-in-view=false (avoid the OSIV anti-pattern warning).
- Explicit JWT block: secret (>= 32 bytes for jjwt HS256),
issuer, ttl — all DEVSLAB_JWT_* overridable. Default secret
is dev-only and the YAML comment says so.
- Surface devslab.kit.audit.async-queue-capacity and
devslab.kit.menu.cache-ttl on env vars so an integration test
can tighten or disable them.
Verification
------------
- ./gradlew build green (55 tasks; SampleApplicationTests boots
the full context against Testcontainers Postgres + runs the
new seed runner successfully).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sets up the sample app so the admin UI can log in immediately. Needed for end-to-end verification of the full stack (admin-ui + devslab-kit) — previously the app booted with zero users and the UI's login screen had nothing to authenticate against.
Seed runner
SampleSeedRunneris anApplicationRunnerbean registered bySampleApplication. On first boot it provisions:defaultPLATFORM_ADMINbound to that tenantadmin.*permissions covering every admin-api endpoint:admin.user.read/write,admin.role.read/write,admin.permission.read/write,admin.group.read/write,admin.menu.read/write,admin.tenant.read/writeadmin.policy.test,admin.audit.read,admin.diagnostics.run,admin.settings.readadmin.*permission granted toPLATFORM_ADMINadmin / admin(overridable) holdingPLATFORM_ADMINEvery step is idempotent (
findByCode/findByLoginIdbefore create). Re-running on an already-seeded DB is a no-op.SampleSeedProperties(sample.seed.*)enabledtrueSAMPLE_SEED_ENABLEDadmin-login-idadminSAMPLE_SEED_ADMIN_LOGIN_IDadmin-passwordadminSAMPLE_SEED_ADMIN_PASSWORDadmin-emailadmin@example.comSAMPLE_SEED_ADMIN_EMAILDisable in production-like runs with
sample.seed.enabled=false.application.yamlupgradesdevslab-kit-admin-ui's docker-compose stands up by default (jdbc:postgresql://localhost:5432/devslab_kit,devslab/devslab). All four values overridable viaDEVSLAB_DATASOURCE_*.DEVSLAB_REDIS_*.jpa.open-in-view=false(avoid the OSIV warning).DEVSLAB_JWT_*overridable. Default secret is dev-only and the YAML comment says so.devslab.kit.audit.async-queue-capacityanddevslab.kit.menu.cache-ttlon env vars so an integration test can tighten or disable them.Verification
./gradlew buildgreen (55 tasks)SampleApplicationTestsboots the full context against Testcontainers Postgres + runs the new seed runner successfullydocker compose up -d postgres redis(in admin-ui) →./gradlew :devslab-kit-sample-app:bootRun(in devslab-kit) →npm run dev(in admin-ui) → log in asadmin / adminand walk through every CRUD pageWhy now
This is the missing piece for the integration e2e verification phase. The 23 admin endpoints, the 10 UI pages, and the seed all need to line up against the same running stack for the contract gaps to be exercised end-to-end (not just per-spec in unit tests).